package com.wty.learnsping.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet(name = "MyServlet1",urlPatterns = "*.test1",loadOnStartup = 1)
public class MyServlet1 extends HttpServlet {

    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("MyServlet1 init config");
    }

//    @Override
//    public void init() throws ServletException {
//        System.out.println("MyServlet1 init");
//    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().print("this is MyServlet1");
        System.out.println("this is MyServlet1");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.service(req, resp);
    }


    @Override
    public void destroy() {
        System.out.println("MyServlet1 destory");
    }
}
